package com.qst.msg.controller;

import com.qst.domain.entity.Mess;
import com.qst.msg.service.MsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/msg")
public class MsgController {

    @Autowired
    MsgService msgService;

    @PostMapping("/addMsg")
    public Mess addMsg(String title, String message, @RequestParam(required = false) String togroup, @RequestParam(required = false) String towhose){
        return msgService.addMsg(title,message,togroup,towhose);
    }

    @GetMapping("/getMsg")
    public Mess getMsg(@RequestHeader("id")Integer id){
        return msgService.getMsg(id);
    }

    @GetMapping("/getCount")
    public Mess getCount(@RequestHeader("id")Integer id){
        return msgService.getCount(id);
    }

    @PostMapping("/readMsg")
    public Mess readMsg(@RequestHeader("id")Integer id){
        return msgService.readMsg(id);
    }
}
